import java.util.Scanner;

/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2022-05-07
 * Time:22:20
 */
public class HomeWork {
    private static void toString(int []arr){
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]);
            if (i<arr.length-1){
                System.out.print(",");
            }
        }
        System.out.print("]");
    }
    public static void main(String[] args) {
        //实现一个方法 toString, 把一个整型数组转换成字符串. 例如数组 {1, 2, 3} , 返回的字符串为 "[1, 2, 3]", 注意 逗号 的位置和数量.
        int []arr={1,2,3,4,5,6,7,8,9,10};
        toString(arr);
    }
}
  /*  private static void copyOf(int []arr1,int []arr2){
        for (int i = 0; i < arr1.length; i++) {
            arr2[i]=arr1[i];
        }
    }
    public static void main(String[] args) {
        //实现一个方法 copyOf, 对一个整型数组进行拷贝, 得到一个新的数组.
        int []arr1={1,2,3,4,5,6,7,8,9,10};
        int []arr2=new int[arr1.length];
        copyOf(arr1,arr2);
        for (int i = 0; i < arr1.length; i++) {
            System.out.print(arr2[i]+" ");
        }
    }
}*/
    /*public static int TwoLook(int[]arr,int key){
        int left = 0;
        int right = arr.length-1;
        while(left<=right) {
            int mid = (left + right) / 2;
            if (key < arr[mid]) {
                right = mid - 1;
            } else if (key>arr[mid]){
                left = mid + 1;
            }else{
                return mid;
            }
        }
        return -1;
    }
    public static void main(String[] args) {
        //给定一个有序整型数组, 实现二分查找
        int []arr={1,2,3,4,5,6,7,8,9,10};
        int num = 0;
        Scanner scanner=new Scanner(System.in);
        System.out.print("请输入要查找的数字:");
        while(scanner.hasNext()){
            num = scanner.nextInt();
            if (TwoLook(arr, num)!=-1){
                System.out.println(num+"的下标为:"+TwoLook(arr, num));
            }
            else{
                System.out.println("没有找到!");
            }
            System.out.print("请输入要查找的数字:");
        }
    }
}*/
    /*public static void judgeNums(int []nums){
        int ret = 0;
        for (int i = 0; i < nums.length-1; i++) {
            if (nums[i]<nums[i+1]){
                ret = 1;
            }
        }
        if (ret == 1){
            System.out.println("nums是有序数组");
        }else{
            System.out.println("nums不是有序数组");
        }
    }
    public static void main(String[] args) {
        //给定一个整型数组, 判定数组是否有序（递增）
        int []nums=new int[]{1,2,3,4,5,6,7,8,9,10};
        judgeNums(nums);
        }
    }
*/
